Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add Enumeration states to XTCE parser #783

Merged

Conversation

greglucas
Copy link
Collaborator

@greglucas greglucas commented Aug 26, 2024

Change Summary

Overview

This adds the ability to include derived enumeration states from the "States" tab in the spreadsheets.

Testing

Manual testing with SWE's packet definition. Unfortunately it looks like we don't have any tests for this utility and it is a pain to mock up the spreadsheets. This should be an action item to do in the future though.

closes #782

This adds the ability to include derived enumeration states from
the "States" tab in the spreadsheets.
@greglucas greglucas added the packet parsing Related to packet parsing or XTCE label Aug 26, 2024
@@ -329,6 +328,10 @@ def _add_parameter(self, row: pd.Series, total_packet_bits: int) -> None:
# Go look up the conversion in the AnalogConversions tab
# and add it to the encoding
self._add_analog_conversion(row, encoding)
elif row["convertAs"] == "STATE":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice that this column and that tab was connected. I knew that they stored enums(derived) values in that tab but didn't connect those two together. Nice!

for _, state_row in state_sheet.iterrows():
enumeration = Et.SubElement(enumeration_list, "xtce:Enumeration")
enumeration.attrib["value"] = str(state_row["value"])
enumeration.attrib["label"] = str(state_row["state"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if this function produces something like this?

	        <xtce:EnumeratedParameterType name="QUARTER_CYCLE_ENUM" signed="false">
                <xtce:IntegerDataEncoding sizeInBits="5" encoding="unsigned"/>
                <xtce:EnumerationList>
                    <xtce:Enumeration label="FIRST" value="0"/>
                    <xtce:Enumeration label="SECOND" value="1"/>
		   <xtce:Enumeration label="THIRD" value="2"/>
                    <xtce:Enumeration label="FORTH" value="3"/>
                </xtce:EnumerationList>
            </xtce:EnumeratedParameterType>

I saw most of it but didn't see it add this line. I think we need that.

                <xtce:IntegerDataEncoding sizeInBits="5" encoding="unsigned"/>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is taken care of in the above _add_parameter_type(), which adds the encodings. Then here we modify that parameter type to be EnumeratedParameterType instead of IntegerParameterType. It should be there if you run this on the swapi or swe definitions (could you verify it works for you as well). This is where tests would be nice...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran locally and it looks correct.

@greglucas
Copy link
Collaborator Author

Unfortunately it looks like we don't have any tests for this utility and it is a pain to mock up the spreadsheets. This should be an action item to do in the future though.

Of course, I totally missed that we had an Excel sheet and expected output in the test_data folder! 🐑

I've changed from that Excel sheet to a dynamically generated Excel file instead as I suggested initially. The expected output file has a minimal diff with the new enumeration updates.

@greglucas greglucas mentioned this pull request Aug 30, 2024
2 tasks
@greglucas greglucas requested a review from bourque August 30, 2024 13:54
@greglucas
Copy link
Collaborator Author

@bourque , I am pinging you to see if you agree with updating/changing the tests here now.

Codecov is now 100% for this diff.

Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good to me!

@greglucas greglucas merged commit 373f9f3 into IMAP-Science-Operations-Center:dev Aug 30, 2024
17 checks passed
@greglucas greglucas deleted the xtce-enumerations branch August 30, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packet parsing Related to packet parsing or XTCE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH - Add enumeration states to XTCE parser
3 participants